<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('客户产品出片CT统计列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label class="control-label is-required">月份：</label>
                                <input type="text" class="input-sm" id="searchCtime" name="searchCtime" required/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="tabQuery()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-danger" onclick="removePageAll()" shiro:hasPermission="report:cusproutlotct:remove">
                    <i class="fa fa-remove"></i> 删除本页记录
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="report:cusproutlotct:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table ">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('report:cusproutlotct:edit')}]];
        var removeFlag = [[${@permission.hasPermi('report:cusproutlotct:remove')}]];
        var partTypeDatas = [[${@dict.getType('commondata_part_type')}]];
        var prefix = ctx + "report/cusproutlotct";
        var tableinit = true;

        var columnArrays = [
            {
                field: 'id',
                title: '编号',
                visible: false
            },
            {
                field: 'timeFlag',
                title: '日期时间标识'
            },
            {
                field: 'calSeq',
                title: '当次序号',
                visible: false
            },
            {
                field: 'partType',
                title: '产品类型',
                formatter: function(value, row, index) {
                    return $.table.selectDictLabel(partTypeDatas, value);
                }
            },
            {
                field: 'customerName',
                title: '客户名称'
            },
            {
                field: 'qty',
                title: '出片数'
            },
            {
                field: 'ct',
                title: '产品生产周期'
            },
            {
                field: 'ctTrendLastMonth',
                title: 'CT对比上月变化趋势'
            }
        ];

        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "客户产品出片CT统计",
            pagination: false,
            columns: columnArrays,
            rowStyle: function (row, index) {    // 动态修改行的颜色
                if (row.customerName == 'TOTAL' || row.partType == 'TOTAL') {
                    return {
                        css: {
                            "background-color": 'rgb(227,224,102)',
                            "color": 'rgb(0,0,0)'
                        }
                    };
                }
                return {
                    css: {
                        "background-color": 'rgb(140,208,138)',
                        "color": 'rgb(0,0,0)'
                    }
                };
            }
        };

        $(function() {
            layui.use('laydate', function(){
                var laydate = layui.laydate;
                laydate.render({
                    elem: '#searchCtime',
                    type: 'month',
                    value: new Date()
                });
            });

        });

        function tabQuery() {
            if (tableinit) {
                $.table.init(options);
                tableinit = false;
            } else {
                $.table.search();
            }
        }

        // 删除本页面记录
        function removePageAll() {
            $.modal.confirm("确认要删除本页数据吗?", function() {
                var ids = [];
                //获取全部数据(本页)
                var list = $("#bootstrap-table").bootstrapTable('getData');
                for (var i = 0; i < list.length; i++) {
                    if (list[i][0] || ($.common.isEmpty(list[i][0]))) {
                        ids.push(list[i].id);
                    }
                }
                // 请求删除数据
                var url = table.options.removeUrl;
                var data = { "ids": ids.join() };
                $.operate.submit(url, "post", "json", data);
            });
        }
    </script>
</body>
</html>